<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<#assign base=request.contextPath  />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title></title>
    <link rel="stylesheet" href="../frame/layui/css/layui.css">
    <link rel="stylesheet" href="../frame/static/css/style.css">
    <link rel="icon" href="../frame/static/image/code.png">
    <script type="text/javascript" src="${base}/js/zhang.js"></script>
    <script type="text/javascript" src="../frame/layui/layui.all.js"></script>
    <script src="${base}/js/jquery-1.8.3.min.js"></script>


</head>
<body class="body">
<div class="ziyemianbiju">
    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
        <div class="my-btn-box">
            <span id="layerDemo">
                <span class="layui-form-label">手机号</span>
                <div class="layui-input-inline">
                    <input type="text" autocomplete="off" placeholder="手机号" class="layui-input isNull isNum" id="phone"
                           style="height: 31px;">
                </div>
                	<button class="layui-btn layui-btn-normal  layui-btn-sm" id="selectphone">查询</button>
            </span>
            <table class="layui-hide" id="test" lay-filter="test"></table>
            <script type="text/html" id="barDemo">
                <betton class="layui-btn layui-btn-normal layui-btn-xs " lay-event="edit">审核</betton>

            </script>
            <!-- table -->
            <table class="layui-hide" id="test" lay-filter="test"></table>
            <script type="text/javascript" src="../frame/layui/layui.all.js"></script>
            <script type="text/javascript" src="../js/index.js"></script>
            <script type="text/javascript">
                // layui方法
                layui.use(['tree', 'table', 'vip_table', 'layer'], function () {

                    // 操作对象
                    var table = layui.table
                            , vipTable = layui.vip_table
                            , layer = layui.layer
                            , $ = layui.jquery;

                    // 表格渲染
                    var tableIns = table.render({
                        even: true,//开启隔行背景
                        size: 'sm',//小尺寸的表格
                        elem: '#test',
                        toolbar: '#toolbarDemo',
                        url: '${base}/comPeople/select',
                        title: '用户数据表',
                        cols: [[
                            {
                                type: 'checkbox',
                                width: 40
                            },
                            {field: 'name', title: '联系人姓名', align: 'center'}
                            , {field: 'phone', title: '联系人手机号', align: 'center'}
                            , {
                                field: 'peoepleUrla',
                                title: '身份证正面照片',
                                align: 'center',
                                templet: function (val) {
                                    var url = val.peoepleUrla;
                                    return '<div><img src="${base}/comPeople/getPhoto?path=' + url + '"></div>'
                                }
                            }
                            , {
                                field: 'peoplea',
                                title: '驾驶证正面照片',
                                align: 'center',
                                templet: function (val) {
                                    var url = val.peoplea;
                                    return '<div><img src="${base}/comPeople/getPhoto?path=' + url + '"></div>'
                                }
                            }
                            , {
                                field: 'flag', title: '是否通过', align: 'center',
                                templet: function (val) {
                                    var flag = val.flag;
                                    if (flag == 2) {
                                        return "不通过"
                                    } else {
                                        return "通过"
                                    }
                                }
                            }
                            , {field: 'falseInfo', title: '未通过原因', align: 'center'}
                            , {field: 'eczxxxxema', title: '操作', align: 'center', toolbar: '#barDemo'}
                        ]]
                        , id: 'dataCheck'
                        , method: 'get'
                        ,height:480
                        ,page: {
                            layout: ['limit', 'count', 'prev', 'page', 'next', 'skip']
                            ,theme: '#9AC747'
                            ,limit: 10
                        }
                    });


                    //页面传参
                    table.on('tool(test)', function (obj) {
                        var layEvent = obj.event;
                        if (layEvent == "edit") {
                            var data = obj.data;
                            //示范一个公告层
                            layer.open({
                                type: 2,
                                title: '编辑',
                                shadeClose: false,
                                offset: 't',
                                area: ['100%', '100%'],
                                content: '${base}/comPeople/check.html?peoepleUrla=' + data.peoepleUrla + "&peoepleUrlb=" + data.peoepleUrlb + "&id=" + data.id,
                                success: function (layero, index) {
                                    //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                                    var iframeWin = window[layero.find('iframe')[0]['name']];

                                    iframeWin.$("#name").val(data.name);
                                    iframeWin.$("#phone").val(data.phone);

                                    iframeWin.$("#peoepleUrla").val(data.peoepleUrla);
                                    iframeWin.$("#peoepleUrlb").val(data.peoepleUrlb);
                                    iframeWin.$("#flag").val(data.flag);
                                    iframeWin.$("#falseInfo").val(data.falseInfo);
                                    iframeWin.$("#id").val(data.id);
                                    //渲染一下form表单
                                    iframeWin.layui.form.render('select');
                                    iframeWin.layui.form.render();
                                }
                            });
                        }

                    });

                });

                $("body").bind("keydown", function (e) {
                    // 兼容FF和IE和Opera
                    var theEvent = e || window.event;
                    var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
                    if (code == 13) {
                        //回车执行查询
                        $("#selectphone").click();
                    }
                });

                //根据手机查询
                $('#selectphone').on('click', function () {
                    var phone = $("#phone").val();
                    if(!isNum()){
                        alert("请输入数字")
                        return;
                    }
                    if (phone==null || phone==''){
                        var table = layui.table;
                        table.reload(
                                'dataCheck', {
                                    url: '${base}/comPeople/select',

                                });
                    } else {
                        var table = layui.table;
                        table.reload(
                                'dataCheck', {
                                    url: '${base}/comPeople/selectphone',
                                    where: {phone: phone} //设定异步数据接口的额外参数
                                });
                    }
                })


            </script>
</body>
</html>